package com.ideaction.controller;

import com.ideaction.game.utils.IpUtils;
import com.ideaction.globalconst.Result;
import com.ideaction.req.PlayerCommonReqBody;
import com.ideaction.service.LoginServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


/**
 * @author ZGame 登陆控制器 登陆的目的就是为了更新token,客户端后面的操作必须拿着token,服务器才会接受 账户集合和玩家数据集合拆开,每次登陆的时候只需要更新下账户集合
 */
@RestController
public class LoginController {
    
    @Autowired
    private LoginServiceImp loginServiceImp;
    
    @PostMapping("/Login")
    public String login(@RequestBody PlayerCommonReqBody playerLoginReqBody, HttpServletRequest request) {
        return loginServiceImp.login(playerLoginReqBody, IpUtils.getClientIp(request));
    }
    
    @PostMapping("LoginHttpMessageProcessor")
    public String loginHttpMessageProcessor(@RequestBody PlayerCommonReqBody playerLoginReqBody) {
        return Result.build().response();
        //return loginServiceImp.loginHttpMessageProcessor(playerLoginReqBody);
    }
    
}
